<template>
  <default-layout>
    <header-back text="我的继续教育" slot="header"></header-back>
    <div slot="main">
      <div class="form-list">
        <div class="form-list-item">
          <span class="label">姓名：</span>
          <span class="content">{{info.aac003}}</span>
        </div>
        <div class="form-list-item">
          <span class="label">身份证号：</span>
          <span class="content">{{info.aac002}}</span>
        </div>
        <div class="form-list-item">
          <span class="label">工作单位：</span>
          <span class="content">{{info.company}}</span>
        </div>
        <div class="form-list-item">
          <span class="label">报名课程：</span>
          <span class="content">{{info.course}}</span>
        </div>
        <div class="form-list-item">
          <span class="label">学习年份：</span>
          <span class="content">{{info.learnYear}}</span>
        </div>
        <div class="form-list-item">
          <span class="label">学习状态：</span>
          <span class="content">{{info.learnStatus}}</span>
        </div>
      </div>
      <div class="form">
        <yd-cell-group>
          <yd-cell-item>
            <span slot="left" class="label required">学习资料：</span>
            <upload-image-group v-model="images" slot="right" file-name="学习资料" type="20" :max="5"></upload-image-group>
          </yd-cell-item>
        </yd-cell-group>
      </div>
      <div class="next">
        <mt-button size="large" type="primary" @click="onSubmit">提交申请</mt-button>
      </div>
    </div>
  </default-layout>
</template>
<script>
  import HeaderBack from '../../../components/header-back/header-back.vue'
  import DefaultLayout from '../../../layouts/default-layout/default-layout'
  import UploadImageGroup from '../../../components/upload-image-group/upload-image-group'
  import {arrToForm} from '../../../common/js/util'

  export default {
    components: {
      UploadImageGroup,
      DefaultLayout,
      HeaderBack},
    data() {
      return {
        images: [],
        info: {}
      }
    },
    methods: {
      onSubmit() {
        if (!this.images.length) {
          this.$message.toast('请上传学习资料')
          return
        }
        this.$post('/admin/person/sapi/education/continuing/get/upload/testresults', {
          applyId: this.$route.query.applyId,
          yearId: this.$route.query.yearId,
          learnYear: this.info.learnYear,
          ...arrToForm(this.images, 'attachmentList')
        }, loading => { this.$message.loading(loading) }).then(res => {
          this.$message.alert(res.message).then(() => {
            this.$router.replace({
              name: 'myApply',
              params: {id: 4}
            })
          })
        })
      },
      getInfo() {
        this.$post('/admin/person/sapi/education/continuing/get/detail/info', {
          applyId: this.$route.query.applyId,
          yearId: this.$route.query.yearId
        }, loading => { this.$message.loading(loading) }).then(res => {
          this.info = res.data
        })
      }
    },
    created() {
      this.getInfo()
    }
  }
</script>
<style lang="scss" scoped>
  @import "../../../common/style/variable";
  .form{
    margin: .15rem 0 0 0;
  }
  .next{
    padding: .15rem 0 0 0;
  }
</style>
